package huawei;
/*
* @Author: wanghongfucoder
* @Date:   2017-06-28 14:29:43
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-06-28 14:29:56
*/

import java.util.Scanner;
 
public class DayCount {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int year=Integer.parseInt(sc.next());
            int month=Integer.parseInt(sc.next());
            int day=Integer.parseInt(sc.next());
            int[] arr={0,31,28,31,30,31,30,31,31,30,31,30,31};
            if(isoddyear(year)){
                arr[2]=29;
            }
            int sum=0;
            for (int i = 0; i < month; i++) {
                sum+=arr[i];
            }
            sum=sum+day;
            System.out.println(sum);
        }
 
    }
    public static boolean isoddyear(int year){
        if(year%4==0&&year%100!=0||year%400==0){
            return true;
        }else{
            return false;
        }
    }
 
}